# Maintainer: Bruno Pagani <archange@archlinux.org>

pkgbase=v4l2loopback
pkgname=(v4l2loopback-dkms v4l2loopback-utils)
pkgver=0.12.7
pkgrel=2
pkgdesc="v4l2-loopback device"
arch=(any)
url="https://github.com/umlaeute/v4l2loopback"
license=(GPL2)
makedepends=(help2man)
source=(${url}/archive/v${pkgver}/${pkgbase}-${pkgver}.tar.gz
        ${pkgbase}-fix-kernel-5.18+-compat.patch::${url}/commit/e7edf2f55b7eb71b69984110f3c8e31b8ac6285e.patch)
sha256sums=('e0782b8abe8f2235e2734f725dc1533a0729e674c4b7834921ade43b9f04939b'
            '9c5e36952666576ca4d735537f55e5076f461c9ebe4db8bd5cbd3fee80da3389')

prepare() {
  patch -p1 -d ${pkgbase}-${pkgver} < ${pkgbase}-fix-kernel-5.18+-compat.patch
}

package_v4l2loopback-dkms() {
  pkgdesc+=" – module sources"
  depends=(dkms)
  provides=(V4L2LOOPBACK-MODULE)
  cd ${pkgbase}-${pkgver}
  install -Dm644 v4l2loopback.c v4l2loopback_formats.h dkms.conf Makefile -t "${pkgdir}"/usr/src/${pkgbase}-${pkgver}/
}
package_v4l2loopback-utils() {
  pkgdesc+=" – utilities only"
  depends=(V4L2LOOPBACK-MODULE)
  cd ${pkgbase}-${pkgver}
  make DESTDIR="${pkgdir}" PREFIX="/usr" install-utils install-man
  install -Dm644 COPYING -t "${pkgdir}"/usr/share/licenses/${pkgbase}
}
